<!DOCTYPE html>
<html lang="en">
<head>
	<meta charset="UTF-8">
	<title>全选全不选反选</title>
</head>
<body>
	<input type="checkbox"  >
	<input type="checkbox"  >
	<input type="checkbox"  >
	<input type="checkbox"  >
	<input type="checkbox"  >
	<button onclick="func(1)" >全选</button>
	<button onclick="func(2)" >全不选</button>
	<button onclick="func(3)" >反选</button>
</body>
	<script>
		list = document.getElementsByTagName("input");
		function func(e){
			for(var i=0;i<list.length;i++){
				switch(e){
					case 1:
						list[i].checked = true;
						break;
					case 2:
						list[i].checked = false;
						break;
					case 3:
						list[i].checked = !list[i].checked;
						break;
				}
			}
		}
	</script>
</html>